using System;
using System.Collections.Generic;
using System.Text;
using SubSonic;

namespace MyCityCab.Core
{
    public partial class CityController
    {
        public CityCollection SearchCities(string prefix, int countryId,int maxResult)
        {
            CityCollection coll = new CityCollection();
            Query query = City.CreateQuery();
            query.Top = maxResult.ToString();
            query.WHERE(City.Columns.EnglishName, Comparison.Like, "%" + prefix + "%")
                 .AND(City.Columns.CountryId, countryId)
                 .ORDER_BY(City.Schema.GetColumn(City.Columns.EnglishName));
            coll.LoadAndCloseReader(query.ExecuteReader());
            return coll;
        }
    }
}
